If a private
field is declared but not used locally, its limited visibility makes it dead code.
This is either a sign that some logic is missing or that the code should be cleaned.
Cleaning out dead code decreases the size of the maintained codebase, making it easier to understand and preventing bugs from being introduced.
class MyClass {
public:
int compute(int a) {
return a * 42;
}
int publicField = 0; // Compliant: might be used somewhere else
private:
int foo = 42; // Noncompliant: foo is unused and should be removed
};